/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package be;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author root : Zavaleta De la Cruz Yury Daniel
 * Copyright 2011 Zavaleta De la Cruz Yury Daniel

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

 */
@Entity
@Table(name = "DETALLE_CAMBIO_PRENDA", catalog = "agropecuario", schema = "")
@NamedQueries({
    @NamedQuery(name = "DetalleCambioPrenda.findAll", query = "SELECT d FROM DetalleCambioPrenda d"),
    @NamedQuery(name = "DetalleCambioPrenda.findByIdCambio", query = "SELECT d FROM DetalleCambioPrenda d WHERE d.detalleCambioPrendaPK.idCambio = :idCambio"),
    @NamedQuery(name = "DetalleCambioPrenda.findByIdPrendaCambio", query = "SELECT d FROM DetalleCambioPrenda d WHERE d.detalleCambioPrendaPK.idPrendaCambio = :idPrendaCambio"),
    @NamedQuery(name = "DetalleCambioPrenda.findByIdPrendaCambiada", query = "SELECT d FROM DetalleCambioPrenda d WHERE d.detalleCambioPrendaPK.idPrendaCambiada = :idPrendaCambiada")})
public class DetalleCambioPrenda implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetalleCambioPrendaPK detalleCambioPrendaPK;
    @JoinColumn(name = "ID_PRENDA_CAMBIADA", referencedColumnName = "ID_PRENDA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Prenda prenda;
    @JoinColumn(name = "ID_PRENDA_CAMBIO", referencedColumnName = "ID_PRENDA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Prenda prenda1;
    @JoinColumn(name = "ID_CAMBIO", referencedColumnName = "ID_CAMBIO", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Cambio cambio;

    public DetalleCambioPrenda() {
    }

    public DetalleCambioPrenda(DetalleCambioPrendaPK detalleCambioPrendaPK) {
        this.detalleCambioPrendaPK = detalleCambioPrendaPK;
    }

    public DetalleCambioPrenda(int idCambio, int idPrendaCambio, int idPrendaCambiada) {
        this.detalleCambioPrendaPK = new DetalleCambioPrendaPK(idCambio, idPrendaCambio, idPrendaCambiada);
    }

    public DetalleCambioPrendaPK getDetalleCambioPrendaPK() {
        return detalleCambioPrendaPK;
    }

    public void setDetalleCambioPrendaPK(DetalleCambioPrendaPK detalleCambioPrendaPK) {
        this.detalleCambioPrendaPK = detalleCambioPrendaPK;
    }

    public Prenda getPrenda() {
        return prenda;
    }

    public void setPrenda(Prenda prenda) {
        this.prenda = prenda;
    }

    public Prenda getPrenda1() {
        return prenda1;
    }

    public void setPrenda1(Prenda prenda1) {
        this.prenda1 = prenda1;
    }

    public Cambio getCambio() {
        return cambio;
    }

    public void setCambio(Cambio cambio) {
        this.cambio = cambio;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detalleCambioPrendaPK != null ? detalleCambioPrendaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleCambioPrenda)) {
            return false;
        }
        DetalleCambioPrenda other = (DetalleCambioPrenda) object;
        if ((this.detalleCambioPrendaPK == null && other.detalleCambioPrendaPK != null) || (this.detalleCambioPrendaPK != null && !this.detalleCambioPrendaPK.equals(other.detalleCambioPrendaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "be.DetalleCambioPrenda[detalleCambioPrendaPK=" + detalleCambioPrendaPK + "]";
    }

}
